/*
 * @Author: szx
 * @Date: 2022-04-02 19:26:41
 * @LastEditTime: 2022-04-02 19:29:52
 * @Description:
 * @FilePath: \leetcode\剑指offerII\029\029.js
 */
/**
 * @param {Node} head
 * @param {number} insertVal
 * @return {Node}
 */
var insert = function (head, insertVal) {
    let cur = head;
    let min = Infinity;
    while (cur.val != min) {
        if (cur.val < min) min = cur.val;
        cur = cur.next;
    }
    let prev = cur;
    while (cur.val < insertVal) {
        prev = cur;
        cur = cur.next;
    }
    const node = new Node(insertVal);
    node.next = prev.next;
    prev.next = node;
    return node;
};
